import getData from '../../service/getData.js'
import * as types from '../types'

const state = {
    loading: 0,
    noMoreCoupon:0,
    loadingText:'正在载入更多数据',
    headText:'',
    backShow:false,
    mesShow:false,
    windowH:'',
    comPage:1,
    pageLimit:10,
    cardShow:false,
    slideLeft:false,
    backCenter:false,
    backHome:false
}

const actions = {

}

const getters = {
    loading: state => state.loading,
    noMoreCoupon: state => state.noMoreCoupon,
}

const mutations = {
    [types.UP_DATA_LIST](state,payload){
        payload.array.splice(payload.index,1);
    },
    [types.COM_LOADING_STATUS](state, status) {
        if (state.loading == 0 && !status) {
            return;
        }
        state.loading = status ? ++state.loading : --state.loading;
    },
    [types.NO_MORE_COUPONLIST](state, status){
        state.noMoreCoupon = status ? ++state.noMoreCoupon : --state.noMoreCoupon;
    },
    [types.LOADING_TEXT](state, text){
        state.loadingText = text
    },
    [types.HEAD_TEXT](state, text){
        state.headText = text
    },
    [types.HEAD_BACK_ICON](state, status){
        state.backShow = status
    },
    [types.HEAD_MES_ICON](state, status){
        state.mesShow = status
    },
    [types.CENTER_BACK_ICON](state, status){
        state.backCenter = status
    },
    [types.HOME_BACK_ICON](state, status){
        state.backHome = status
    },
    [types.WINDOW_HEIGHT](state, height){
        state.windowH = height
    },
    [types.COM_PAGE](state, num){
        state.comPage = num
    },
    [types.HEAD_CARD_ICON](state, status){
        state.cardShow = status
    },
    [types.CHANGE_CARD](state, status){
        state.slideLeft = status
    }
}

export default {
    state,
    actions,
    getters,
    mutations
}